package org.linlinjava.litemall.admin.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger在线文档配置<br>
 * 项目启动后可通过地址：http://host:ip/swagger-ui.html 查看在线文档
 *
 * @author enilu
 * @version 2018-07-24
 */

@Configuration
@EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class AdminSwagger2Configuration {
   @Bean(value = "createRestApi")
   public Docket createRestApi() {
       return new Docket(DocumentationType.SWAGGER_2)
               .groupName("admin")
               .apiInfo(new ApiInfoBuilder()
                       .title("litemall-admin API")
                       .description("litemall管理后台API")
                       .contact(new Contact("一粒云", null, null))
                       .version("1.0")
                       .build())
               .select()
               //.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
               .apis(RequestHandlerSelectors.basePackage("org.linlinjava.litemall.admin.controller"))
               .paths(PathSelectors.any())
               .build();
   }
}
